package 简单的策略模式.商场促销;

import 简单的工厂模式.工厂模式demo.商场促销.CashNormal;
import 简单的工厂模式.工厂模式demo.商场促销.CashRebate;
import 简单的工厂模式.工厂模式demo.商场促销.CashReturn;
import 简单的工厂模式.工厂模式demo.商场促销.CashSuper;

/**
 * @author zyl
 * @Description
 * @since 2023/12/26 13:54
 */

public class CashContext {
    private CashSuper cashSuper;

    public CashContext(int cashType) {
        switch (cashType){
            case 1:
                this.cashSuper = new CashNormal();
                break;
            case 2:
                this.cashSuper = new CashRebate(0.8d);
                break;
            case 3:
                this.cashSuper = new CashRebate(0.7d);
                break;
            case 4:
                this.cashSuper = new CashReturn(300d,100d);
                break;
        }
    }
    public double getPriceResults(double price, int num){
        return this.cashSuper.acceptCash(price, num);
    }
}
